﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSharpCode.SharpZipLib.Zip;
using System.IO;

namespace InnovTech.Util.Zip
{
    public static class SharpZipUtil
    {
        public static string CompressFolder(string sourceFolder, string targetDirPath)
        {
            FastZip zip = new FastZip();

            string targetFileName = sourceFolder.Split('\\').Last() + ".zip";
            targetFileName = Path.Combine(targetDirPath, targetFileName);

            zip.CreateZip(targetFileName, sourceFolder, true, null);
            zip = null;
            return targetFileName;
        }

        public static void CompressFolder(String sourceFolder, Stream output)
        {
            FastZip zip = new FastZip();

            zip.CreateZip(output, sourceFolder, true, null, null);
            zip = null;
        }

        
    }
}
